package com.mask.mk.controller;


import com.mask.mk.service.GOrderService;
import com.mask.mk.util.JsonResult;
import com.mask.mk.vo.goods.UploadGoodsRequest;
import com.mask.mk.vo.order.AddOrderRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 订单表 前端控制器
 * </p>
 *
 * @author joey
 * @since 2023-04-25
 */
@Api(tags = "订单管理")
@RestController
@RequestMapping("/g-order")
public class GOrderController {

    @Autowired
    private GOrderService gOrderService;

    @ApiOperation(value = "生成订单")
    @PostMapping("/addOrder")
    public JsonResult addOrder(@RequestBody AddOrderRequest addOrderRequest){
        System.out.println("订单数据 =>" + addOrderRequest);
       return gOrderService.addOrder(addOrderRequest);
    }

    @ApiOperation(value = "获取所有订单")
    @GetMapping("/getAllOrder")
    public JsonResult getAllOrder(){
        return gOrderService.getAllOrder();
    }


    @ApiOperation(value = "结算页面-获取订单")
    @PostMapping("/getOrderCheckPage")
    public JsonResult getOrderCheckPage(@RequestBody AddOrderRequest addOrderRequest){
        System.out.println("订单数据 =>" + addOrderRequest);
        return gOrderService.getCheckOrderPage(addOrderRequest);
    }

    @ApiOperation(value = "个人中心-获取订单")
    @PostMapping("/getOrderUserPage")
    public JsonResult getOrderUserPage(@RequestBody AddOrderRequest addOrderRequest){
        System.out.println("订单数据 =>" + addOrderRequest);
        return gOrderService.getOrderList(addOrderRequest);
    }

    @ApiOperation(value = "修改订单状态") //orderid status
    @PostMapping("/changeOrder")
    public JsonResult changeOrder(@RequestBody AddOrderRequest addOrderRequest){
        System.out.println("订单数据 =>" + addOrderRequest);
        return gOrderService.updateOrder(addOrderRequest);
    }

}

